﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cms.Core.Infrastructure.Ui;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace Cms.Core.Validation.FluentValidations
{
    public class ValidateResultFormatHandler : IValidateResultFormatHandler
    {
        public void Format(ResultExecutingContext context)
        {
            //只返回第一条错误信息
            context.Result = new JsonResult(new  AjaxResult(context.ModelState.Values.First().Errors[0].ErrorMessage,Infrastructure.Common.AjaxResultType.Error));
        }

      
    }
}
